#
# Makefile for Assignment 1
#
XCC     = gcc
AS	= as
AR  = ar
LD      = ld
CFLAGS  = -c -fPIC -Wall -I. -I/u/wbcowan/cs452/io/include -mcpu=arm920t -msoft-float
# -g: include hooks for gdb
# -c: only compile
# -mcpu=arm920t: generate code for the 920t architecture
# -fpic: emit position-independent code
# -Wall: report all warnings

ASFLAGS	= -mcpu=arm920t -mapcs-32

ARFLAGS = rcs

# -mapcs: always generate a complete stack frame

LDFLAGS = -init main -Map a1.map -N  -T orex.ld -L/u/wbcowan/gnuarm-4.0.2/lib/gcc/arm-elf/4.0.2 -L/u/wbcowan/cs452/io/lib
TEST_LDFLAGS = -init main -Map test.map -N  -T orex.ld -L/u/wbcowan/gnuarm-4.0.2/lib/gcc/arm-elf/4.0.2 -L/u/wbcowan/cs452/io/lib

all:  a1.s a1.elf test.s test.elf

a1.s: a1.c a1.h
	$(XCC) -S $(CFLAGS) a1.c

a1.o: a1.s
	$(AS) $(ASFLAGS) -o a1.o a1.s

a1.elf: a1.o
	$(LD) $(LDFLAGS) -o $@ a1.o -lbwio -lgcc

test.s: test.c test.h
	$(XCC) -S $(CFLAGS) test.c

test.o: test.s
	$(AS) $(ASFLAGS) -o test.o test.s

test.elf: test.o
	$(LD) $(TEST_LDFLAGS) -o $@ test.o -lbwio -lgcc

clean:
	-rm -f *.elf *.s *.o *.map
